package com.ppc.mapper.user;

import com.github.pagehelper.Page;
import com.ppc.entity.Conversation;
import com.ppc.entity.Employer;
import com.ppc.entity.Message;
import com.ppc.entity.Worker;
import com.ppc.vo.ConversationVO;
import com.ppc.vo.MessageVO;
import java.time.LocalDateTime;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 聊天的mapper
 *
 * @author jianKangS1
 * @date 2023/12/20
 */
@Mapper
public interface ChatMapper {

  @Select("select * from employer where employer_id=#{employerId}")
  Employer selectEmployerId(Long employerId);

  @Select("select user_id from worker where worker_id=#{workerId}")
  Worker selectWorkerId(Long workerId);


  Page<ConversationVO> employerPageConversationQuery(Long userId);


  Conversation selectConversation(Long userIdOne, Long userIdTwo);


  void insertConversation(Conversation conversationDTO);

  void insertMessageForEmployer(Long userId, Message message);

  List<MessageVO> selectMessage(Long conversationId, LocalDateTime timeAfter);

  void insertMessageForWorker(Long workerId, Message message);

  Page<ConversationVO> workerPageConversationQuery(Long workerId);

  void readMessage(Long userId, Long conversationId);


  Conversation checkConversationExists(Conversation conversation);
}
